<?php

include_once '../Core/Conexion.php';
include_once '../Core/Controlador.php';
include_once '../Core/InterfazDatos.php';
//include_once '../../../../Core/Conexion.php';
include_once '../entidades/Usuario.php';
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Grabar
 *
 * @author home
 */
class Control extends Controlador
{
   function __construct() {
        parent::__construct();
    }
    
    public function ejecutar() 
    {
           
        
            $consulta=$this->conexion->consultaLibre("SELECT * FROM TBL_USUARIO WHERE USU_NICK='".$_POST['nick']."' AND USU_CLAVE='".$_POST['clave']."'");
            $fila=mysql_fetch_array($consulta);
            
            $valor=  mysql_num_rows($consulta);
            
            if($valor==0)
            {
                header("Location: ../login.php?mensaje=1");                
            }
            else
            {
               
				session_start();           
				$_SESSION['nick']=$fila[1];
                                $_SESSION['tipo']=$fila[3];
				
				if($_SESSION['tipo']=="admin")
				{
					 header("Location: ../administrador/index.php");
				}
				
				if($_SESSION['tipo']=="gestor")
				{
					header("Location: ../gestor/index.php");
				}
				
				if($_SESSION['tipo']=="usuario")
				{
                                        $_SESSION['titular']=$fila[4];
					header("Location: ../usuario/index.php");
				}
				
            }
            

            
    }    //put your code here
}

$controlador=new Control();
$controlador->ejecutar();